//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <cstdlib>

#include <iostream>
#include <fstream>

#include "CompactMotifSequence.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main(int argc, char** argv) {

  String* filenameFASTAIn;
  String* filenameMotifIn;
  String* filenameResiduesIn;
  String* location;

  String* filenameSeqOut;
  String* filenameMotifOut;
  String* filenameError;

  if (argc < 8) {
    cout << "Error in the input arguments. The execution must be: " << endl;
    cout << "./GetCompactMotifSequence <Input fasta file> <Input Motif file> <Input Residue file> <location DB> <output sequences file> <output compacts motifs file> <error file>" << endl;
    return 0;
  }
  else {
    cout << "---------------------------------------------------------------------------------" << endl;
    cout << "            Input Fasta File : " << argv[1] << endl;
    cout << "            Input Motif File : " << argv[2] << endl;
    cout << "         Input Residues File : " << argv[3] << endl;
    cout << "           Location Database : " << argv[4] << endl;
    cout << "       Output Sequences File : " << argv[5] << endl;
    cout << " Output Compacts Motifs File : " << argv[6] << endl;
    cout << "                Output Error : " << argv[7] << endl;
    cout << "---------------------------------------------------------------------------------" << endl;
    filenameFASTAIn    = new String(argv[1]);
    filenameMotifIn    = new String(argv[2]);
    filenameResiduesIn = new String(argv[3]);
    location           = new String(argv[4]);
    filenameSeqOut     = new String(argv[5]);
    filenameMotifOut   = new String(argv[6]);
    filenameError      = new String(argv[7]);
  }

  CompactMotifSequence* compactMotifSequence = new CompactMotifSequence();

  compactMotifSequence->FilenameFASTA(filenameFASTAIn);
  compactMotifSequence->FilenameMotif(filenameMotifIn);
  compactMotifSequence->FilenameListRES(filenameResiduesIn);
  compactMotifSequence->LocationDB(location);

  compactMotifSequence->ConstructReduceBindingSiteMotif(filenameSeqOut, filenameMotifOut, filenameError);

  cout << "---------------------------------------------------------------------------------" << endl;

  if (filenameSeqOut)   delete filenameSeqOut;
  if (filenameMotifOut) delete filenameMotifOut;
  if (filenameError)    delete filenameError;

  return 1;

}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//



